package com.gnerv.sylvanas.framework.common.tools;

/**
 * 分页工具
 *
 * @author Gnerv LiGen
 */
public class PageTools {

    private PageTools() {
    }

    /**
     * 默认分页最大300条数据
     */
    public static final int MAX_SIZE = 300;

    public static int limitStart(int current, int size) {
        if (current < 1) {
            current = 1;
        }
        return (current - 1) * limitSize(size);
    }

    public static int limitSize(int size) {
        if (size < 1 || size > MAX_SIZE) {
            size = 30;
        }
        return size;
    }
}
